package wx

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/mini/wx"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// OfficialPayService 微信公众号/小程序支付服务
type OfficialPayService struct {
	*services.BaseService
}

// NewOfficialPayService 创建微信公众号/小程序支付服务
func NewOfficialPayService(config *core.Config) *OfficialPayService {
	return &OfficialPayService{
		BaseService: services.NewBaseService(config),
	}
}

// OfficialPay 微信公众号/小程序支付
func (s *OfficialPayService) OfficialPay(request *wx.OfficialPayRequest) (*wx.OfficialPayResponse, error) {
	response := wx.NewOfficialPayResponse()
	err := s.Post(request, response, "/open/trans/officialpay")
	if err != nil {
		return nil, err
	}
	return response, nil
}
